package edu.xcdq;

import java.util.Scanner;
//13.insert(位置，插入的内容)
public class Demo02 {
    /**
     * StringBuffer 是String的增强类，加了缓冲区，效率更高
     * @param args
     */
    public static void main(String[] args) {
       StringBuffer sb = new  StringBuffer("生活不知眼前苟且");
       StringBuffer sb1 = sb.append(",");
        System.out.println(sb1);     //等价于 System.out.println(sb1.toString());
        StringBuffer sb2 =  sb1.append("还有诗和远方");
        System.out.println(sb2);
        StringBuffer sb3 =sb2.append(false);
        System.out.println(sb3);

        System.out.println("请输入一串数字：");
        Scanner sc = new Scanner(System.in);
         String s1 = sc.next();
         StringBuffer  sb4 = new StringBuffer(s1);
         for (int i =sb4.length()-3;i>0;i=i-3){
             sb4.insert(i,",");
         }
          System.out.println(sb4);
    }
}
